package com.os.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.os.service.UserServiceM;
import com.os.serviceimpl.UserServiceImplM;

import net.sf.json.JSONObject;

public class RegistControllerM extends HttpServlet{
	UserServiceM us=new UserServiceImplM();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	// TODO Auto-generated method stub
	doPost(req, resp);
}
@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
	req.setCharacterEncoding("utf8");
	req.setCharacterEncoding("utf8");
	String uname=req.getParameter("uname");
	String upsd=req.getParameter("upsd");
	String ridname=req.getParameter("rid");
	int rid=0;
	if(ridname.equals("点菜员")){
		rid=1;
	}else if(ridname.equals("后厨")){
		rid=2;
	}else if(ridname.equals("经理")){
		rid=3;
	}
	boolean isRegist=us.regist(uname, upsd, rid);
	JSONObject j=new JSONObject();
	j.put("isRegist", isRegist);
	PrintWriter pw=resp.getWriter();
	pw.write(j.toString());
	}
}
